Skip to content

Implement managed ForwardMultidim using separable 1D FFT#1151

Open
bryancostanich wants to merge 1 commit intomathnet:masterfrom
bryancostanich:fix/managed-forward-multidim
Open

Implement managed ForwardMultidim using separable 1D FFT#1151
bryancostanich wants to merge 1 commit intomathnet:masterfrom
bryancostanich:fix/managed-forward-multidim

Conversation

@bryancostanich
Copy link
Copy Markdown

Summary

Implements ManagedFourierTransformProvider.ForwardMultidim and BackwardMultidim using separable 1D FFT decomposition (process each dimension independently using existing 1D FFT).

Previously these methods threw NotSupportedException, making Fourier.Forward2D() and Fourier.Inverse2D() unusable without a native provider (MKL).

Motivation

On platforms where MKL is unavailable (macOS ARM64, other non-x86 targets), multi-dimensional FFT was completely broken. The fix is straightforward since the 1D managed FFT already works correctly.

Implementation

  • For each dimension of the N-D array, extract 1D slices along that dimension, apply the existing 1D FFT, and write results back
  • Handles both power-of-two (Radix-2) and non-power-of-two (Bluestein) dimension sizes
  • Scaling is applied once after all dimensions are processed, matching MKL provider behavior
  • Works for arbitrary N-D arrays, not just 2D

Tests

Added four new tests to FourierTest.cs:

  • Forward2DAndInverse2DRoundtrip64 -- Complex64 roundtrip with random data (4x8)
  • Forward2DAndInverse2DRoundtrip32 -- Complex32 roundtrip with random data (4x8)
  • Forward2DKnownDCValue64 -- Constant array produces energy only in DC bin (4x4)
  • Forward2DNonPowerOfTwoDimensions64 -- Non-power-of-two dimensions (3x5) exercise Bluestein path

All 87 FFT tests pass on both net8.0 and net48.

Fixes #1150

The managed provider now supports multi-dimensional FFT using separable
1D FFT decomposition (row-wise then column-wise). Previously these
methods threw NotSupportedException, making Fourier.Forward2D() and
Fourier.Inverse2D() unusable without a native provider (MKL).

Fixes mathnet#1150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ManagedFourierTransformProvider.ForwardMultidim throws NotSupportedException

1 participant